﻿<%@ Page Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="ReporteParticipantesPosiblesEnPromocion.aspx.cs"
    Inherits="CrmContacto.WebApp.App.ReporteParticipantesPosiblesEnPromocion" %>

<%@ Import Namespace="Web.Framework.Translate" %>
<asp:Content ID="HeaderContent" ContentPlaceHolderID="HeadContent" runat="server">
    <script src="/Scripts/App/PlanDeMarketingEdit.js" type="text/javascript"></script>
    <script src="/Scripts/App/SearchMini.js" type="text/javascript"></script>    
</asp:Content>
<asp:Content ID="BodyContent" ContentPlaceHolderID="MainContent" runat="server">
    <h2>
        <asp:Image Width="15px" Height="15px" ID="imgExpandResults" CssClass="imgExpand"
            ImageUrl="/Images/icon_blockexpanded.png" runat="server" ClientIDMode="Static"
            alt="" onclick="window.AppCommonObj.toggleVisibility(this.id, 'searchBox');" />
        <asp:Literal ID="Literal22" runat="server" Text='<%$ Code: LocalizationProvider.Instance["Bo.Promociones.FiltroParticipantesPromo"]%>' />
    </h2>
    <div class="editionContainerFilter" id="searchBox">
        <p>
            <span class="title2">
                <asp:Literal ID="Literal5" runat="server" Text='<%$ Code:  LocalizationProvider.Instance["DiscriminadorAccionDeMarketing.Promocion"]%>' />:</span>
            <asp:DropDownList ID="cboPromociones" runat="server" CssClass="cbo" ClientIDMode="Static">
            </asp:DropDownList>
        </p>
        <div class="divp">
            <span class="title2 secondColumn">
                <asp:Literal ID="Literal19" runat="server" Text='<%$ Code: LocalizationProvider.Instance["Bo.SearchContacto.CantidadDeRegistros"]%>' />:</span>
            <asp:DropDownList ID="cboRegistros" runat="server" CssClass="cbo" ClientIDMode="Static">
            </asp:DropDownList>
        </div>
        <div class="clear">
        </div>
        <p>
            <span class="title2">
                <asp:Literal ID="litFechaEventoDesde" runat="server" Text='<%$ Code:  LocalizationProvider.Instance["AccionDeMarketing.FechaEventoDesde"]%>' />:</span>
            <asp:TextBox ID="txtFechaDesde" runat="server" CssClass="inputs" ClientIDMode="Static"></asp:TextBox>
        </p>
        <div class="divp" runat="server" id="divFechaEventoHasta">
            <span class="title2 secondColumn">
                <asp:Literal ID="Literal7" runat="server" Text='<%$ Code:  LocalizationProvider.Instance["AccionDeMarketing.FechaEventoHasta"]%>' />:</span>
            <asp:TextBox ID="txtFechaHasta" runat="server" CssClass="inputs" ClientIDMode="Static"></asp:TextBox>
            <div class="clear">
            </div>
        </div>
        <div class="clear">
        </div>
        <p>
            <span class="title2">
                <asp:Literal ID="Literal2" runat="server" Text='<%$ Code: LocalizationProvider.Instance["Bo.Reporte.VentasPorCliente.ContactosEmail"]%>' />:</span>
            <asp:TextBox ID="txtContactosEmail" runat="server" ClientIDMode="Static" CssClass="inputs inputlong"
                title='<%$ Code: LocalizationProvider.Instance["Bo.Reporte.VentasPorCliente.ContactosEmail.Hint"]%>'></asp:TextBox>
            <img src="/Images/consulta.png" id='imgSearchCustomer' alt='search image' />
        </p>
        <div class="clear">
        </div>
        <p id="pUsaCupon">
            <span class="title2">
                <asp:Literal ID="Literal6" runat="server" Text='<%$ Code:  LocalizationProvider.Instance["Promocion.GeneroCupon"]%>' />:</span>
            <asp:DropDownList ID="cboSubConjuntoDeAplicacion" runat="server" CssClass="cbo" ClientIDMode="Static">
            </asp:DropDownList>
        </p>
        <div class="clear">
        </div>
        <asp:Panel ID="pnlExtraControls" runat="server">
            <%--Panel para ubicar filtros especiales según la promoción--%>
        </asp:Panel>
        <div class="clear">
        </div>
        <asp:LinkButton ID="lnkBuscar" runat="server" OnClick="lnkBuscar_Click" OnClientClick="return ValidarBuscar();">
            <asp:Literal ID="Literal3" runat="server" Text='<%$ Code: LocalizationProvider.Instance["Bo.Command.Buscar"]%>' /></asp:LinkButton>
        <a href="#" onclick="javascript:document.forms[0].reset();">
            <asp:Literal ID="Literal4" runat="server" Text='<%$ Code: LocalizationProvider.Instance["Bo.Command.Limpiar"]%>' /></a>
        <div class="clear">
        </div>
    </div>
    <asp:Panel ID="pnlResults" CssClass="editionContainerForGrid" runat="server" ClientIDMode="Static">
        <div style="float: left">
            <h2>
                <asp:Image Width="15px" Height="15px" ID="Image1" CssClass="imgExpand" ImageUrl="/Images/icon_blockcollapsed.png"
                    runat="server" ClientIDMode="Static" alt="" onclick="window.AppCommonObj.toggleVisibility(this.id, 'pnlGrilla');" />
                <asp:Literal ID="Literal1" runat="server" Text='<%$ Code: LocalizationProvider.Instance["Bo.Promociones.ListadoDeParticipantes"]%>' />
                <asp:Label ID="lblSearchResult" runat="server" Text="" CssClass="lblSearchResult"></asp:Label>
            </h2>
        </div>
        <div id="pnlGrilla">
            <div class="divExportarAExcelGrid">
                <asp:LinkButton ID="lnkExportarAExcel" CssClass="promolnkExportarAExcel" ClientIDMode="Static"
                    OnClick="lnkExportarAExcel_Click" runat="server">
                    <img style="text-decoration: none; border: 0px; margin-right: 4px" src="../Images/excel.png"
                        alt="" /><asp:Literal ID="Literal24" runat="server" Text='<%$ Code: LocalizationProvider.Instance["Bo.SearchContacto.CmdExportarExcel"]%>' /></asp:LinkButton>
            </div>
            <div class="clear">
            </div>
            <asp:ObjectDataSource ID="CustomerObjectDs" runat="server" TypeName="Web.Framework.Search.GridViewSearchObjectDataSource"
                SortParameterName="sortExpression" SelectMethod="GetObjects" SelectCountMethod="TotalNumberOfGetObjects"
                EnablePaging="True" OnObjectCreating="CustomerObjectDs_ObjectCreating" OnSelected="Grid_Selected">
            </asp:ObjectDataSource>
            <asp:GridView ID="Grid" runat="server" CellPadding="4" ForeColor="#333333" DataSourceID=""
                ViewStateMode="Enabled" GridLines="None" AutoGenerateColumns="False" DataKeyNames="Id"
                Width="100%" AllowPaging="True" PageSize="15" OnPageIndexChanging="Grid_PageIndexChanging"
                OnRowCommand="Grid_RowCommand" OnRowDataBound="Grid_RowDataBound" AllowSorting="False"
                OnDataBound="Grid_DataBound">
                <AlternatingRowStyle BackColor="White" />
                <Columns>
                    <asp:TemplateField HeaderText="">
                        <HeaderStyle HorizontalAlign="Left" Width="30px" />
                        <ItemStyle HorizontalAlign="Center" />
                        <ItemTemplate>
                            <asp:ImageButton ID="btnEditar" runat="server" ImageUrl="~/Images/editar.png" CommandName="editar"
                                CommandArgument="<%# ((GridViewRow) Container).RowIndex %>" />
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:BoundField DataField="Email" HeaderText='<%$ Code:  LocalizationProvider.Instance["Contacto.Email"] %>'
                        SortExpression="Email">
                        <HeaderStyle HorizontalAlign="Left" />
                    </asp:BoundField>
                    <asp:BoundField DataField="Nombre" HeaderText='<%$ Code:  LocalizationProvider.Instance["Contacto.Nombre"] %>'
                        SortExpression="Nombre">
                        <HeaderStyle HorizontalAlign="Left" />
                    </asp:BoundField>
                    <asp:BoundField DataField="Apellido" HeaderText='<%$ Code:  LocalizationProvider.Instance["Contacto.Apellido"] %>'
                        SortExpression="Apellido">
                        <HeaderStyle HorizontalAlign="Left" />
                    </asp:BoundField>
                    <asp:BoundField DataField="TipoDocumentoId" HeaderText='<%$ Code:  LocalizationProvider.Instance["Contacto.TipoDocumento"] %>'
                        SortExpression="TipoDocumentoId">
                        <HeaderStyle HorizontalAlign="Left" />
                    </asp:BoundField>
                    <asp:BoundField DataField="Dni" HeaderText='<%$ Code:  LocalizationProvider.Instance["Contacto.DocumentoShort"] %>'
                        SortExpression="NroDocumento">
                        <HeaderStyle HorizontalAlign="Left" />
                    </asp:BoundField>
                    <asp:BoundField DataField="OrigenPuntoDeVentaId" HeaderText='<%$ Code:  LocalizationProvider.Instance["Contacto.OrigenPuntoDeVentaId"] %>'
                        SortExpression="OrigenPuntoDeVentaId">
                        <HeaderStyle HorizontalAlign="Left" />
                    </asp:BoundField>
                    <asp:BoundField DataField="CumpleDia" HeaderText='<%$ Code:  LocalizationProvider.Instance["Contacto.CumpleanosDia"] %>'
                        SortExpression="CumpleDia">
                        <HeaderStyle HorizontalAlign="Left" />
                    </asp:BoundField>
                    <asp:BoundField DataField="CumpleMes" HeaderText='<%$ Code:  LocalizationProvider.Instance["Contacto.CumpleanosMes"] %>'
                        SortExpression="CumpleMes">
                        <HeaderStyle HorizontalAlign="Left" />
                    </asp:BoundField>
                    <asp:BoundField DataField="CumpleAnio" HeaderText='<%$ Code:  LocalizationProvider.Instance["Contacto.CumpleanosAnio"] %>'
                        SortExpression="CumpleAnio">
                        <HeaderStyle HorizontalAlign="Left" />
                    </asp:BoundField>
                    <asp:BoundField DataField="Telefono" HeaderText='<%$ Code:  LocalizationProvider.Instance["Contacto.Telefono"] %>'
                        SortExpression="Telefono">
                        <HeaderStyle HorizontalAlign="Left" />
                    </asp:BoundField>
                    <asp:BoundField DataField="AuditFechaCreacion" HeaderText='<%$ Code:  LocalizationProvider.Instance["Auditoria.FechaCreacion"] %>'
                        DataFormatString="{0:dd-MM-yyyy}" SortExpression="AuditFechaCreacion">
                        <HeaderStyle HorizontalAlign="Left" />
                    </asp:BoundField>
                    <asp:BoundField DataField="Cupon" HeaderText='<%$ Code:  LocalizationProvider.Instance["Venta.Cupon"] %>'>
                        <HeaderStyle HorizontalAlign="Left" />
                    </asp:BoundField>
                </Columns>
                <EditRowStyle BackColor="#2461BF" />
                <FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
                <HeaderStyle BackColor="#4b6c9e" Font-Bold="True" ForeColor="White" HorizontalAlign="Left" />
                <PagerStyle BackColor="#4b6c9e" ForeColor="White" HorizontalAlign="Center" />
                <RowStyle BackColor="#EFF3FB" />
                <SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
                <SortedAscendingCellStyle BackColor="#F5F7FB" />
                <SortedAscendingHeaderStyle BackColor="#6D95E1" />
                <SortedDescendingCellStyle BackColor="#E9EBEF" />
                <SortedDescendingHeaderStyle BackColor="#4870BE" />
            </asp:GridView>
        </div>
    </asp:Panel>
    <asp:Panel ID="pnlSearchCustomer" runat="server" ClientIDMode="Static" CssClass="displayNone"
        title='<%$ Code: LocalizationProvider.Instance["Bo.CustomerSearchMini.FilterTitle"]%>'
        Width="100%" Height="100%" ScrollBars="None">
        <iframe id="iframeSeachCustomer" src="/App/CustomerSearchMini.aspx" width="100%"
            height="100%" frameborder="0"></iframe>
    </asp:Panel>
    <script type='text/javascript'>

        $(document).ready(function () {

            if (!window.AppCommonObj) {
                window.AppCommonObj = new AppCommon();
            }

            if (!window.SearchMiniJsObj) {
                window.SearchMiniJsObj = new SearchMiniJs();
            }

            window.AppCommonObj.initializeEnterKeyEvent($('#searchBox'), function () {
                __doPostBack($('#lnkBuscar').attr('aspnetid'), '');
            });

            $('#txtFechaDesde').datepick({ dateFormat: 'dd/mm/yyyy' });
            $('#txtFechaHasta').datepick({ dateFormat: 'dd/mm/yyyy' });

            window.SearchMiniJsObj.Initialize($('#imgSearchCustomer'), $('#txtContactosEmail'), $('#pnlSearchCustomer'), $('#iframeSeachCustomer'));


            $('#cboPromociones').change(function () {

                if (window.promociones) {
                    var index = parseInt($(this).val());
                    if (!isNaN(index)) {
                        var stringFecha = promociones[index];
                        var stringFechaSplit = stringFecha.split('##');
                        $('#txtFechaDesde').val(stringFechaSplit[0]);
                        $('#txtFechaHasta').val(stringFechaSplit[1]);
                        var usaCupon = stringFechaSplit[2] == "1";
                        if (usaCupon) {
                            $('#pUsaCupon').show();
                        }
                        else {
                            $('#pUsaCupon').hide();
                        }
                    }
                }
            });

            if ($('#cboPromociones').attr('nochange') == null) {
                $('#cboPromociones').change();
            }

            //$('input[title]').inputHints();

        });

//         Validación
        function ValidarBuscar() {
            var errorPanel = new ErrorPanel();

            var isError = false;
            var strError = '';

            errorPanel.removeErrors();
            var txtDesde = $('#txtFechaDesde');
            var txtHasta = $('#txtFechaHasta');
            var promociones = $('#cboPromociones');

            var separador = '';
            if (txtDesde.val() == '') {
                isError = true;
                errorPanel.appendAsteriskToJQControl(txtDesde);

                strError += separador;
                strError += JsLocalization_ReporteVentasPorClienteJs_IngresarFechaDesde;
                separador = '<br />';
            }

            if (promociones.val() == null) {
                isError = true;
                errorPanel.appendAsteriskToJQControl(promociones);

                strError += separador;
                strError += JsLocalization_ReportePromocion_Seleccionar;
                separador = '<br />';
            }

            if (txtHasta.val() == '') {
                isError = true;
                errorPanel.appendAsteriskToJQControl(txtHasta);

                strError += separador;
                strError += JsLocalization_ReporteVentasPorClienteJs_IngresarFechaHasta;
                separador = '<br />';
            }

            if (isError) {
                errorPanel.showError(JsLocalization_Messages_CompleteElFormulario, strError);
            }

            return !isError;
        };

    </script>
</asp:Content>
